      
<?php
//function created (uses for checking all checkbox and confirm to delete selected item) which is in /js/custom_scripts.js
    echo $javascript->link('custom_scripts');
?>
<div class="index">
<h2><?php echo 'Danh sách nhân viên '.$tendv[0] ['donvis']['tendv']?></h2>
<?php 
if(!empty($dsnhanvien)) 
 //   echo $this->Form->create('Thuocdv');
    echo $this->Form->create('Thuocdv',array('url'=>'adduser/'.$dsnhanvien[0]['Znvuser']['donvi_id']));?>
    <?php echo $this->Html->link(__('Thêm nhân viên mới', true), array('controller'=>'nhanviens','action' => 'add',$id_donvi));?>

<table cellpadding="0" cellspacing="0" id="tables" width="150%">
	<tr>
            <th style="width: 10px;"><input type="checkbox" onclick="checkAll(this);" /></th>
			<th><?php echo 'STT';?></th>
			<th><?php echo 'Mã nhân viên';?></th>
			<th><?php echo 'Chức danh';?></th>
			<th><?php echo 'Tên nhân viên';?></th>
			<th><?php echo 'Trạng thái';?></th>
			<th><?php echo 'Tài khoản';?></th>
			<th class="actions"><?php __('Lựa chọn');?></th>
	</tr>
	<?php
		$i = 0;
        $k=1;
		foreach ($dsnhanvien as $nhanvien):
		$class = null;
		if ($i++ % 2 == 0) 
		{
			$class = ' class="altrow"';
		}
	?>
	<tr<?php echo $class;?>>
        <?php
        if(empty($nhanvien['Znvuser']['user_id'])){
	        echo '<td width="3%"><input type="checkbox" value="'.$nhanvien['Znvuser']['id'].'" 
                    name="data[Znvuser][checked][]" id="'.$k.'" ></td>';
            $k++;
         }
         else echo '<td></td>';
        ?>
		<td><?php echo ($i);//echo $nhanvien['Znvuser']['id']; ?>&nbsp;</td>
		<td><?php echo $nhanvien['Znvuser']['manv']; ?>&nbsp;</td>
		<td>
			<?php echo $nhanvien['Chucdanh']['chucdanh']; ?>
		</td>
		<td><?php echo $nhanvien['Znvuser']['tennv']; ?>&nbsp;</td>
		<td>
			<?php if( $nhanvien['Znvuser']['conlam']==1) echo 'Còn làm'; else echo 'Nghỉ' ?>
		</td>
		<td>
			<?php if(empty($nhanvien['Znvuser']['user_id']))
            	   echo $html->link(__('Tạo TK', true), array('controller'=>'users','action' => 'add', $nhanvien['Znvuser']['id']));
                   else
                    echo $nhanvien['User']['username'].'<br/> '.$html->link(__('Reset password', true), array('controller'=>'users','action' => 'reset', $nhanvien['Znvuser']['user_id'],$nhanvien['Znvuser']['donvi_id']));                     
            
            ?>
			
                     
		</td>
		<td class="actions">
            <?php echo $this->Html->link(__('Chi tiết', true), array('controller'=>'nhanviens','action' => 'view', $nhanvien['Znvuser']['id'],$id_donvi)); ?>
			<?php echo $this->Html->link(__('Sửa', true), array('controller'=>'nhanviens','action' => 'edit', $nhanvien['Znvuser']['id'])); ?>
			<?php echo $this->Html->link(__('Xóa', true), array('controller'=>'nhanviens','action' => 'delete', $nhanvien['Znvuser']['id'],$id_donvi), null, sprintf(__('Bạn muốn xóa nhân viên mã %s?', true), $nhanvien['Znvuser']['manv'])); ?>
		</td>
	</tr>
<?php  endforeach; ?>
</table>
<div align="center" style="margin-top: 5px;"><?php echo $this->Form->end(__('Tạo tài khoản', true));?></div>
</div>